-
Notifications
You must be signed in to change notification settings - Fork 606
Arm backend: Match fp32->int32 cast between pytorch and TOSA's CAST #12243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arm backend: Match fp32->int32 cast between pytorch and TOSA's CAST #12243
Conversation
- Pytorch .to() truncates values toward zeros, while TOSA's CAST rounds values to the nearest int. They will show different behaviours on fp32->int32 casting. - Fix the mismatched behaviour with the following transformation: Before: output = to_copy(x, torch.int32) After: is_non_negative = x >= 0 floor_x = floor(x) ceil_x = ceil(x) decorated_x = where(is_non_negative, floor_x, ceil_x) output = to_copy(decorated_x, torch.int32) Change-Id: I21286432eeb0a5e2f21865f3ac097051c921a9b3 Signed-off-by: Yufeng Shi <yufeng.shi@arm.com>
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/12243
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 1 Cancelled Job, 4 Unrelated FailuresAs of commit 4e19b63 with merge base b342f83 ( NEW FAILURE - The following job has failed:
CANCELLED JOB - The following job was cancelled. Please retry:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but was present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated CI failures. LGTM!
Before:
output = to_copy(x, torch.int32)
After:
is_non_negative = x >= 0
floor_x = floor(x)
ceil_x = ceil(x)
decorated_x = where(is_non_negative, floor_x, ceil_x)
output = to_copy(decorated_x, torch.int32)
Change-Id: I21286432eeb0a5e2f21865f3ac097051c921a9b3
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218